package nmrworkflow.framework.beans;

import nmrworkflow.framework.beans.datasets.NmrDataSet;
import nmrworkflow.framework.beans.datatypes.Streamable;

public class NmrDataSetFactory
{	
	public static NmrDataSet create(Class type)
	{
		NmrDataSet dataSet = null;
		
		try
		{
			Object o = type.newInstance();
			if(o instanceof NmrDataSet)
				dataSet = (NmrDataSet) o;
		} catch(Exception e)
		{
			// can't instantiate, just return null
		}
		
		return dataSet;
	}
	
	public static NmrDataSet create(Class type, Streamable data)
	{
		NmrDataSet dataSet = create(type);
		
		if(dataSet != null)
			dataSet.setData(data);
		
		return dataSet;
	}
}
